package com.shell.guard.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.oauth2.provider.error.WebResponseExceptionTranslator;
import org.springframework.util.Assert;

import com.shell.guard.exception.CustomWebResponseExceptionTranslator;

@Configuration
public class ServiceConfig {
	@Autowired
	private DataSource dataSource;

	@Bean
	public WebResponseExceptionTranslator webResponseExceptionTranslator() {
		return new CustomWebResponseExceptionTranslator();
	}

	@Bean
	public JdbcTemplate jdbcTemplate() {
		Assert.notNull(this.dataSource, "DataSource required");
		return new JdbcTemplate(this.dataSource);
	}
}
